package com.ldg.crm.dao;

import com.ldg.crm.entity.ProductEntity;
import com.ldg.crm.entity.ProductEntityExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface ProductDao {
    /**
     *
     * @mbg.generated
     */
    @SelectProvider(type=ProductEntitySqlProvider.class, method="countByExample")
    long countByExample(ProductEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @DeleteProvider(type=ProductEntitySqlProvider.class, method="deleteByExample")
    int deleteByExample(ProductEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @Delete({
        "delete from crm_product",
        "where product_id = #{productId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer productId);

    /**
     *
     * @mbg.generated
     */
    @Insert({
        "insert into crm_product (product_id, compact_id, ",
        "product_type_id, sn, ",
        "product_date, production_date, ",
        "comment)",
        "values (#{productId,jdbcType=INTEGER}, #{compactId,jdbcType=INTEGER}, ",
        "#{productTypeId,jdbcType=INTEGER}, #{sn,jdbcType=VARCHAR}, ",
        "#{productDate,jdbcType=DATE}, #{productionDate,jdbcType=DATE}, ",
        "#{comment,jdbcType=LONGVARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="productId", before=true, resultType=Integer.class)
    int insert(ProductEntity record);

    /**
     *
     * @mbg.generated
     */
    @InsertProvider(type=ProductEntitySqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="productId", before=true, resultType=Integer.class)
    int insertSelective(ProductEntity record);

    /**
     *
     * @mbg.generated
     */
    @SelectProvider(type=ProductEntitySqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="product_id", property="productId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="compact_id", property="compactId", jdbcType=JdbcType.INTEGER),
        @Result(column="product_type_id", property="productTypeId", jdbcType=JdbcType.INTEGER),
        @Result(column="sn", property="sn", jdbcType=JdbcType.VARCHAR),
        @Result(column="product_date", property="productDate", jdbcType=JdbcType.DATE),
        @Result(column="production_date", property="productionDate", jdbcType=JdbcType.DATE),
        @Result(column="comment", property="comment", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<ProductEntity> selectByExampleWithBLOBs(ProductEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @SelectProvider(type=ProductEntitySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="product_id", property="productId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="compact_id", property="compactId", jdbcType=JdbcType.INTEGER),
        @Result(column="product_type_id", property="productTypeId", jdbcType=JdbcType.INTEGER),
        @Result(column="sn", property="sn", jdbcType=JdbcType.VARCHAR),
        @Result(column="product_date", property="productDate", jdbcType=JdbcType.DATE),
        @Result(column="production_date", property="productionDate", jdbcType=JdbcType.DATE)
    })
    List<ProductEntity> selectByExample(ProductEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @Select({
        "select",
        "product_id, compact_id, product_type_id, sn, product_date, production_date, ",
        "comment",
        "from crm_product",
        "where product_id = #{productId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="product_id", property="productId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="compact_id", property="compactId", jdbcType=JdbcType.INTEGER),
        @Result(column="product_type_id", property="productTypeId", jdbcType=JdbcType.INTEGER),
        @Result(column="sn", property="sn", jdbcType=JdbcType.VARCHAR),
        @Result(column="product_date", property="productDate", jdbcType=JdbcType.DATE),
        @Result(column="production_date", property="productionDate", jdbcType=JdbcType.DATE),
        @Result(column="comment", property="comment", jdbcType=JdbcType.LONGVARCHAR)
    })
    ProductEntity selectByPrimaryKey(Integer productId);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=ProductEntitySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") ProductEntity record, @Param("example") ProductEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=ProductEntitySqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") ProductEntity record, @Param("example") ProductEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=ProductEntitySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") ProductEntity record, @Param("example") ProductEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=ProductEntitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(ProductEntity record);

    /**
     *
     * @mbg.generated
     */
    @Update({
        "update crm_product",
        "set compact_id = #{compactId,jdbcType=INTEGER},",
          "product_type_id = #{productTypeId,jdbcType=INTEGER},",
          "sn = #{sn,jdbcType=VARCHAR},",
          "product_date = #{productDate,jdbcType=DATE},",
          "production_date = #{productionDate,jdbcType=DATE},",
          "comment = #{comment,jdbcType=LONGVARCHAR}",
        "where product_id = #{productId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(ProductEntity record);

    /**
     *
     * @mbg.generated
     */
    @Update({
        "update crm_product",
        "set compact_id = #{compactId,jdbcType=INTEGER},",
          "product_type_id = #{productTypeId,jdbcType=INTEGER},",
          "sn = #{sn,jdbcType=VARCHAR},",
          "product_date = #{productDate,jdbcType=DATE},",
          "production_date = #{productionDate,jdbcType=DATE}",
        "where product_id = #{productId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ProductEntity record);
}